package com.waves.user.service;

import com.waves.common.domain.dto.PushMessageDTO;
import com.waves.core.constant.MQConstant;
import com.waves.websocket.domain.vo.WSBaseVO;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Description:
 * Author: dlw
 * Date: 2024-08-12
 */
@Service
public class PushService {

    @Resource
    private RabbitTemplate rabbitTemplate;

    public void sendPushMsg(WSBaseVO<?> msg, List<Long> uidList) {
        rabbitTemplate.convertAndSend(MQConstant.ORDER_EVENT_EXCHANGE, MQConstant.WEBSOCKET_PUSH_MSG, new PushMessageDTO(uidList, msg));
    }

    public void sendPushMsg(WSBaseVO<?> msg, Long uid) {
        rabbitTemplate.convertAndSend(MQConstant.ORDER_EVENT_EXCHANGE, MQConstant.WEBSOCKET_PUSH_MSG, new PushMessageDTO(uid, msg));
    }

    public void sendPushMsg(WSBaseVO<?> msg) {
        rabbitTemplate.convertAndSend(MQConstant.ORDER_EVENT_EXCHANGE, MQConstant.WEBSOCKET_PUSH_MSG, new PushMessageDTO(msg));
    }
}
